<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="css/research.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
    <script>
            window.onload = function() {
    var picnav = document.getElementById("picture-nav");//这种方式只能在id dom下获取子节点
    var li = picnav.getElementsByTagName("li"); //获取picnav下的li标签的dom 以便对下标的操作
    var banner = document.getElementById("banner");
    var div = banner.getElementsByTagName("div"); //获取banner下的的div图片区dom

    for (var i = 0; i < li.length; i++) { //获取所有i编号的元素
        li[i].index = i; //定义一个index属性对li进行编号
        li[i].onclick = function() { //再注册一个点击事件，当点击的时候所有标签都恢复最初状态
            for (var n = 0; n < li.length; n++) { //这步是相对于未被点击部分的样式
                li[n].className = "";
                div[n].className = "hidden";
            }
            this.className = "on"; //再对点击事件添加相应的属性
            div[this.index].className = ""; //通过之前的index编号绑定的指定div
        }
    }
}
        </script>
        <style>

                #tab{
                    margin-left:5px !important;
                    text-align:center;
                    margin-top:30px!important;
                    width:1300px;
                }
                #th{
                    font-size: 17px;
                    font-weight: 600;
                    line-height: 22px;
                    color: #FF0099;
                }
                #tr{
                    font-size: 17px;
                    font-weight: 600;
                    line-height: 22px;
                    color: rgb(0, 132, 137);
                }
                
                
        </style>

</head>

<body>
    <?php
// 创建连接
$conn = mysql_connect("localhost:3306","root","wohenpi0918");
mysql_set_charset('utf8',$conn);
//编码，避免出现乱码
mysql_select_db("student",$conn);
//连接数据库
// 检测连接
if (!$conn) {
    die("Connection failed: " . mysql_connect_error());
}
$sql="SELECT * FROM rent where id='01'";
$result=mysql_query($sql,$conn)or die(mysql_error());
// 取出结果集数据
$row=mysql_fetch_assoc($result);

$sql1="SELECT * FROM rent where id='02'";
$result1=mysql_query($sql1,$conn)or die(mysql_error());
// 取出结果集数据
$row1=mysql_fetch_assoc($result1);

$sql2="SELECT * FROM rent where id='03'";
$result2=mysql_query($sql2,$conn)or die(mysql_error());
// 取出结果集数据
$row2=mysql_fetch_assoc($result2);

$sql3="SELECT * FROM rent where id='04'";
$result3=mysql_query($sql3,$conn)or die(mysql_error());
// 取出结果集数据
$row3=mysql_fetch_assoc($result3);

$sql4="SELECT * FROM rent where id='05'";
$result4=mysql_query($sql4,$conn)or die(mysql_error());
// 取出结果集数据
$row4=mysql_fetch_assoc($result4);

$sql5="SELECT * FROM rent where id='06'";
$result5=mysql_query($sql5,$conn)or die(mysql_error());
// 取出结果集数据
$row5=mysql_fetch_assoc($result5);
?>
    <div class="main-container">
        <div class="header-wrap">
            <div class="nav-img">

            </div>
            <form id="form" action="research.php" method="POST">

                <div class="search-div">
                    <input class="search" type="text" placeholder="请输入房源相关信息">
                </div>
                <div class="button" onclick="document.getElementById('form').submit()">
                    搜房
                </div>
            </form>

            <div id="ball"></div>

        </div>

        <div class="ul-div">
            <ul id="ul1">
                <li><a class="active" href="RentHouse.php">HOME</a></li>
                <li><a href="login.php">注册</a></li>
                <li><a href="issue.php">免费发布</a></li>
                <li><a href="#about">商务楼</a></li>
                <li><a href="#about">小区楼</a></li>
                <li><a href="#about">二手房</a></li>
                <li><a href="#about">生意转让</a></li>
                <li><a href="#about">厂房</a></li>
                <li class="admin">
                    <a href="managelogin.php" target="_blank"><img src="img/管理员.png" class="img1" alt="管理员登陆">管理员登陆</a>
                </li>
            </ul>

        </div>

        <div class="changepicture">
            <div id="picture-nav">
                <ul class="ul">
                    <li class="on">理想</li>
                    <li>憧憬</li>
                    <li>生活</li>
                    <li>现实</li>
                </ul>
            </div>
            <div id="banner">
                <div id="slide1">

                </div>
                <div id="slide2" class="hidden">

                </div>
                <div id="slide3" class="hidden">

                </div>
                <div id="slide4" class="hidden">

                </div>
            </div>

        </div>
        <div class="information">
        <table id="tab"  width="700px" border="1px" class="table table-striped table-bordered table-hover">

            <tr id="th">
                <th>id</th>
                <th>房屋地址</th>
                <th>房屋面积</th>
                <th>楼层</th>
                <th>租金</th>
                <th>区域</th>
                <th>类型</th>
                <th>朝向</th>
                <th>周围环境</th>
                <th>装修情况</th>
                <th>发布人</th>
                </tr>

    <?php
            // 创建连接
            $conn = mysql_connect("localhost:3306","root","wohenpi0918");
            mysql_set_charset('utf8',$conn);
            //编码，避免出现乱码
            mysql_select_db("student",$conn);
            //连接数据库
            // 检测连接
            if (!$conn) {
                 die("Connection failed: " . mysql_connect_error());
                 }
        
        $keywords=$_POST['keywords'];
        // echo $keywords;
        $sql="SELECT * FROM rent where type like '%$keywords%'
        UNION SELECT * FROM rent where id = '$keywords'
        UNION SELECT * FROM rent where address like '%$keywords%'
        UNION SELECT * FROM rent where rentmoney like '%$keywords%'
        UNION SELECT * FROM rent where proportion = '$keywords'
        UNION SELECT * FROM rent where floor = '$keywords'
        UNION SELECT * FROM rent where area like '%$keywords%'
        UNION SELECT * FROM rent where direction like '%$keywords%'
        UNION SELECT * FROM rent where surr like '%$keywords%'
        UNION SELECT * FROM rent where decoration like '%$keywords%'";
        $result=mysql_query($sql,$conn)or die(mysql_error());
        $num=mysql_num_rows($result);
        
        for($i=0;$i<$num;$i++){
            $row=mysql_fetch_assoc($result);
            echo "<tr id='tr'>";
            echo "<td>{$row['id']}</td>";
            echo "<td>{$row['address']}</td>";
            echo "<td>{$row['proportion']}</td>";
            echo "<td>{$row['floor']}</td>";
            echo "<td>{$row['rentmoney']}</td>";
            echo "<td>{$row['area']}</td>";
            echo "<td>{$row['type']}</td>";
            echo "<td>{$row['direction']}</td>";
            echo "<td>{$row['surr']}</td>";
            echo "<td>{$row['decoration']}</td>";
            echo "<td>{$row['issuer']}</td>";
            echo "</tr>" ;}
    ?>

</table>  



<?php

        $keywords=$_POST['keywords'];
        // echo $keywords;
        $sql="SELECT * FROM rent where type like '%$keywords%'
        UNION SELECT * FROM rent where id = '$keywords'
        UNION SELECT * FROM rent where address like '%$keywords%'
        UNION SELECT * FROM rent where rentmoney like '%$keywords%'
        UNION SELECT * FROM rent where proportion = '$keywords'
        UNION SELECT * FROM rent where floor = '$keywords'
        UNION SELECT * FROM rent where area like '%$keywords%'
        UNION SELECT * FROM rent where direction like '%$keywords%'
        UNION SELECT * FROM rent where surr like '%$keywords%'
        UNION SELECT * FROM rent where decoration like '%$keywords%'";
        $result1=mysql_query($sql,$conn)or die(mysql_error());
        $num1=mysql_num_rows($result1);
        
        for($i=0;$i<$num;$i++){
        $row=mysql_fetch_assoc($result1);
        $url="{$row['url']}";
      echo "<div class='div3'>"; 
      echo "<a href='#House1'><div class='img'><img src='img/$url' width='410px' height='274px'></div></a>";    
      echo " <div class='text'>";      
      echo "  <span class='pro'>房屋面积： {$row['proportion']}</span><br>";         
      echo " <span class='ad'>地址：  {$row['address']} </span><br>";            
      echo "   <strong>租金：{$row['rentmoney']} </strong><br>";          
      echo " <span class='tp'>租房类型： {$row['type']} </span>";           
      echo "</div>";       
      echo " </div>";   
   }
?>
</div>




</div>
  


<!-- <script type="text/javascript" scr="js/main.js"></script> -->
</body>

</html>